#!/bin/sh
#统一命名网卡文件

CentOS_NETWORK_DIR="/etc/sysconfig/network-scripts/";
NETWORK_FILE="ifcfg-eth0"
###修改网卡配置文件名称
function net () {
	cd $CentOS_NETWORK_DIR
	network_file=`ls|find ifcfg-e*`
	mv $network_file $NETWORK_FILE
	##修改网卡模式为static
	sed -i 's/dhcp/static/g' $NETWORK_FILE
	##修改name
	sed -i 's/NAME=.*/NAME=\"eth0\"/g' $NETWORK_FILE
	##修改device
	sed -i 's/DEVICE=.*/DEVICE=\"eth0\"/g' $NETWORK_FILE
	##删除包含IPV6的行
	sed -i '/IPV6/d' $NETWORK_FILE
}
###重新配置grub配置并更新内核
function grub () {
sed -i 's/crashkernel=auto rhgb quiet/crashkernel=auto net.ifnames=0 biosdevname=0 rhgb quiet/g' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
#init 6
}

net
grub
 
